1. /* sdfacosh.cpp by K.Tsuru */
  2. // function ID 3309 DRADIX
  3. /********************************************
  4. inverse hyperbolic (area cosh)
  5. arcosh(x) for x >= 1.0 ... not arccosh
  6. Definition
  7. arcosh(x) = [+|-]log(x + sqrt(x*x - 1) )
  8. For 0 < x - 1.0 << 1.0 a formura
  9. arcosh x = 2*artanh(sqrt( (x-1)/(x+1) ))
  10. is used.
  11. Return a positive value.
  12. **********************************************/
  13. #ifndef SN_H
  14. #include "sn.h"
  15. #endif
  16. SDouble Acosh(const SDouble& x){
  17. SDouble r;
  18. SDouble dev1 = x - ONE;
  19. if(dev1.Sign(3309) < 0) x.SetError(x.DOMAIN_ERR, "Acosh",3309); //x < 1
  20. // x >= 1
  21. if(dev1.Sign() == 0){ // x = 1
  22. r.SetZero(); return r;
  23. }
  24. // x > 1
  25. int dev1exp = dev1.NetRdxExp();
  26. if(dev1exp < -1){ // x - 1.0 < DRADIX^(-2)
  27. // arcosh x = 2*artanh(sqrt( (x-1)/(x+1) ))
  28. r = (x+ONE)/dev1; // (x+1)/(x-1)
  29. r = RecSqrt(r); // r < 1/DRADIX
  30. r = AtanhSeries(r);
  31. r = DsMult(r, 2);
  32. } else{
  33. r = x + Sqrt(dev1*(x + ONE)); // r = x+Sqrt(x*x -1)
  34. r = Log(r);
  35. }
  36. return r;
  37. }

sdfacosh.cpp : last modifiled at 2016/08/29 16:43:32(1,019 bytes)
created at 2017/10/07 10:22:50
The creation time of this html file is 2017/10/07 11:29:39 (Sat Oct 07 11:29:39 2017).